<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>招聘新增</title>
<link rel="stylesheet" href="../../css/ecp.min.css" />
<script src="../../js/lib.min.js"></script>
<script src="../../js/requirejsConfigObj.js"></script>
<script src="../../js/requirejs/2.1.17.js"></script>
<script src="../../js/common.min.js"></script>

<style  type="text/css">
    .check_error{color:red;border-color:red;}
    .width130{width:460px;height: 25px;}
    .errText{margin-left:10px;visibility:hidden; }
</style>    
</head>
<body> 
  <div id="showMsg" class="project"></div> 
  <div class="project-dialog"> 
   <form id="formItem" name="formItem" style="width: 100%;"> 
     <div>
      <table class="form_table" width="95%"> 
       <tbody id="table_tbody">
       <tr>
            <td width="130">
                 <label class="description"> <span class="fn-high">*</span>招聘标题</label>
            </td>
            <td width="260" colspan="3">
                <input type="text" class="inputWidth width130" maxlength="100" name="recruitNm" id="recruitNm"/>                   
            </td>            
       </tr>
       <tr>
            <td width="130">
                 <label class="description"> <span class="fn-high">*</span>负责人</label>
            </td>
            <td width="260" colspan="3">
                <input type="text" class="inputWidth width130" maxlength="100" name="persNm" id="persNm"/>                   
            </td>            
       </tr>
       <tr>
            <td width="130">
                 <label class="description"> <span class="fn-high">*</span>联系电话1</label>
            </td>
            <td width="260" colspan="3">
                <input type="text" class="inputWidth width130" maxlength="100" name="telnum" id="telnum" onblur="checkTel(this);"/>                   
            </td>            
       </tr>
       <tr>
            <td width="130">
                 <label class="description"> 联系电话2</label>
            </td>
            <td width="260" colspan="3">
                <input type="text" class="inputWidth width130" maxlength="100" name="telnum2" id="telnum2" onblur="checkTel(this);"/>                   
            </td>            
       </tr>
        <tr>
           <td>
               <label class="description"> <span class="fn-high">*</span>招聘简介</label>
           </td>
           <td colspan="3">
               <textarea type="text" name="recruitDesc" id="recruitDesc" class="form-textarea"  placeholder="请输入500字以内" style="width: 700px;height: 130px;resize:none ;" onblur="true" maxlength="500"></textarea>
           </td>
       </tr>
       <tr>
	        <td>
	            <label class="description"> <span class="fn-high">*</span>招聘介绍</label>
	        </td>
	        <td>
	            <textarea type="text" name="recruitCntt" id=recruitCntt style="width:650px;height:400px;visibility:hidden;"></textarea>
	        </td>
       </tr>       
       </tbody> 
      </table> 
      <hr />
     <div class="formBtnArea"> 
      <table width="100%"> 
       <tbody>
        <tr> 
         <td> 
          <div class="normalBtnArea fn-center"> 
           <input type="hidden" id="recruitId" name="recruitId" value=""/>
           <a class="normalBtn BGblue largeBtn" href="javascript:;" onclick="save()">保存</a> 
           <a href="javascript:;" class="BGblue largeBtn" id="J_cancel" onclick="cancleConfirm()"><span>返回</span></a> 
          </div> 
          </td> 
        </tr> 
       </tbody>
      </table> 
     </div> 
    </div> 
   </form> 
  </div>
 </body>

<script src="../../js/kindeditor/kindeditor-all.js"></script>
<script src="../../js/self_fun.js"></script>
<script type="text/javascript">

$(function(){
	editor = KindEditor.create('textarea[name="recruitCntt"]', {
        allowFileManager: true,
        uploadJson:"/upLoad",
        afterUpload : function(url, data, name) { //上传文件后执行的回调函数，必须为3个参数
            if(name=="image" || name=="multiimage"){ //单个和批量上传图片时
                var img = new Image(); img.src = url;
                img.onload = function(){ //图片必须加载完成才能获取尺寸
                	if(img.width>500) editor.html(editor.html().replace('<img src="' + url + '"','<img src="' + url + '" width="500"'))
                }
            }
        },
        items: [
			'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
			'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
			'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
			'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
			'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
			'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
			'anchor', 'link', 'unlink', '|', 'about'
        ]
      });
	var recruitId = getUrlParam("recruitId");
	$("#recruitId").val(recruitId);
	getRecruitDtl(recruitId);
});
function getRecruitDtl(recruitId){
	$("#recruitNm").val("");
    $("#recruitTypeCd").val("");
    editor.html('');
    $("#recruitDesc").val("");
    $("#telnum").val("");
    $("#telnum2").val("");
    $("#persNm").val('');
	 var param = {'recruitId':recruitId};   
	 Util.ajax.postJsonSync('/getRecruitDtlInfo', param, function(json,status){
       var obj = json.bean;
       if(status){
    	    $("#recruitNm").val(obj.recruitNm);
    	    $("#recruitTypeCd").val(obj.recruitTypeCd);
    	    editor.html(obj.recruitCntt);
    	    $("#recruitDesc").val(obj.recruitDesc);
    	    $("#persNm").val(obj.persNm);
    	    $("#telnum").val(obj.telnum);
    	    $("#telnum2").val(obj.telnum2);
       }else{
           Util.dialog.tips("查询失败,请重试");
       }
	 });
}
function  qryOpAndRaVal(){
    var str = "5000$5023";
    var param={queryType:str};
    Util.ajax.postJsonSync("/home", param, function(json,status){
              alert(json.aaaa);           
    });
}
function save(){  
	var recruitNm = $("#recruitNm").val();
   	if(isDataNull(recruitNm)){
   		top.Util.dialog.tips('请填写招聘标题！');
   	 return;
   	}
   	var persNm = $("#persNm").val();
   	if(isDataNull(persNm)){
   		top.Util.dialog.tips('请填写负责人！');
   	 return;
   	}
   	var telnum = $("#telnum").val();
   	if(isDataNull(telnum) || !checkTelnum(telnum)){
   		top.Util.dialog.tips('请正确填写联系电话1！');
   	 return;
   	}
   	var recruitDesc = $("#recruitDesc").val();
   	if(isDataNull(recruitDesc)){
   		top.Util.dialog.tips('请填写招聘简介！');
   	 return;
   	}   	
	var ntcCnttContent = "";
   	ntcCnttContent = editor.html();
   	if(ntcCnttContent=='' ||ntcCnttContent==null){
    	 top.Util.dialog.tips('请填写招聘介绍！');
    	 return;
    } 
   	var telnum2 = $("#telnum2").val();
   	var recruitId = $("#recruitId").val();
   	var param = {
   		'recruitId':recruitId,
   		'recruitNm':recruitNm,
   		'persNm':persNm,
   		'telnum':telnum,
   		'telnum2':telnum2,
   		'recruitDesc':recruitDesc,
   		'recruitCntt':ntcCnttContent
   	};
	Util.ajax.postJsonSync("/updateRecruitInfo",param,function(json,status){
           if(status){
        	   if(json.bean.rtnCd == "00"){
                   window.parent.inint();
                   window.parent.closeIframeDialog();
               }else{              
                   window.parent.setTip("保存失败",top,2000);
               }
           }else{
               Util.dialog.tips("保存失败,请重试!!");
           }
     }); 
}
function checkTel(_this){
	var str = $(_this).val();
	if(!isDataNull(str)){
		if(!checkTelnum(str)){
			 Util.dialog.tips("请正确填写电话格式");
		}
	}
}
	//取消确认弹框
	function cancleConfirm(){
		//window.location.href = "newProjEstabMana.html?";
		window.parent.closeIframeDialog();
	};
    //表单校验
    var validatePoorHouseInfo = $("#formItem").validate({
    	rules:{
    		recruitNm:{
        		required:true,
        	},
        	recruitTypeCd:{
        		required:true,
        	},
        	recruitDesc:{
        		required:true,
            }
        },
        messages:{
        	recruitNm:{
        		required:"必填",
            },
            recruitTypeCd:{
            	required:"必填",
            },
            recruitDesc:{
            	required:"必填",
            }
        },
        showErrors:function(){
            this.defaultShowErrors();
        }
    });
   
</script>
</body>
</html>